package o;

import com.huawei.appgallery.assistantdock.buoydock.bean.BuoyForumMessageProfiles;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import java.util.ArrayList;
import java.util.List;
import o.bus.c;

public class bfz {
    private static bfz ˋ;
    private Object ˊ = new Object();
    private List<bgb> ˎ = new ArrayList();
    private boolean ˏ = false;

    private bfz() {
    }

    public static synchronized bfz ˊ() {
        bfz o_bfz;
        synchronized (bfz.class) {
            if (ˋ == null) {
                ˋ = new bfz();
            }
            o_bfz = ˋ;
        }
        return o_bfz;
    }

    public boolean ॱ(ezo o_ezo) {
        if (PackageUtils.HWGAMEBOX_PACKAGE_NAME.equals(ContentManager.getInstant().getContext().getPackageName())) {
            return true;
        }
        if (erz.ˎ(ContentManager.getInstant().getContext(), PackageUtils.HWGAMEBOX_PACKAGE_NAME) < 100100300) {
            return false;
        }
        if (o_ezo == null) {
            fae ˏ = fam.ॱ().ˏ();
            if (ˏ != null) {
                GameInfo gameInfo = ˏ.getGameInfo();
                if (gameInfo != null) {
                    ezo ˋ = ezs.ˏ().ˋ(gameInfo);
                    if (ˋ != null) {
                        if (2 != ˋ.ᐝ()) {
                            return false;
                        }
                        return true;
                    }
                }
            }
            return false;
        } else if (2 != o_ezo.ᐝ()) {
            return false;
        } else {
            return true;
        }
    }

    public synchronized void ˎ(final ezo o_ezo, final bfy o_bfy) {
        if (o_ezo != null) {
            if (o_ezo.ॱˊ() != null) {
                o_bfy.ˎ(ˏ(o_ezo, o_ezo.ॱˊ()));
            } else if (UserSession.getInstance().isLoginSuccessful()) {
                ˏ(o_ezo.ᐝ(), new bgb(this) {
                    final /* synthetic */ bfz ˊ;

                    public void ˏ(bvo o_bvo) {
                        if (o_bfy == null) {
                            return;
                        }
                        if (o_bvo == null) {
                            o_bfy.ˎ(false);
                        } else {
                            o_bfy.ˎ(this.ˊ.ˏ(o_ezo, o_bvo));
                        }
                    }
                });
            } else {
                if (Logger.ˎ()) {
                    Logger.ˏ("ForumMsgDisplayManager", "user is not login,isBuoyShowRed, can not request buoy forum display.");
                }
                o_bfy.ˎ(false);
            }
        }
    }

    private boolean ˏ(ezo o_ezo, bvo o_bvo) {
        if (o_ezo == null || o_bvo == null) {
            return false;
        }
        o_ezo.ॱ(o_bvo);
        for (bfo o_bfo : o_ezo.ˎ()) {
            if (!"buoy_gss|forum_msg".equals(o_bfo.ˎ())) {
                if ("buoy_gss|forum_msg_v2".equals(o_bfo.ˎ())) {
                }
            }
            BuoyForumMessageProfiles ˊ = o_bfo.ˊ();
            if (ˊ == null) {
                return false;
            }
            boolean z;
            if ((ˊ.ˊ() <= 0 || !o_bvo.ˋ()) && ((ˊ.ˏ() <= 0 || !o_bvo.ॱ()) && ((ˊ.ॱ() <= 0 || !o_bvo.ˊ()) && ((ˊ.ˋ() <= 0 || !o_bvo.ˏ()) && ((ˊ.ˎ() <= 0 || !o_bvo.ˎ()) && (ˊ.ʻ() <= 0 || !o_bvo.ᐝ())))))) {
                z = false;
            } else {
                z = true;
            }
            return z;
        }
        return false;
    }

    public void ˏ(final ezo o_ezo, final bgc o_bgc) {
        if (o_ezo != null) {
            if (o_ezo.ॱˊ() != null) {
                o_bgc.ˎ(ˎ(o_ezo, o_ezo.ॱˊ()));
            } else if (UserSession.getInstance().isLoginSuccessful()) {
                ˏ(o_ezo.ᐝ(), new bgb(this) {
                    final /* synthetic */ bfz ˏ;

                    public void ˏ(bvo o_bvo) {
                        if (o_bgc == null) {
                            return;
                        }
                        if (o_bvo == null) {
                            o_bgc.ˎ(null);
                        } else {
                            o_bgc.ˎ(this.ˏ.ˎ(o_ezo, o_bvo));
                        }
                    }
                });
            } else {
                if (Logger.ˎ()) {
                    Logger.ˏ("ForumMsgDisplayManager", "user is not login, getSmallBellDisplaySetting, can not request buoy forum display.");
                }
                o_bgc.ˎ(null);
            }
        }
    }

    private boolean ˋ(ezo o_ezo, bvo o_bvo) {
        if (o_ezo == null || o_bvo == null) {
            return false;
        }
        return true;
    }

    private boolean ˎ(String str) {
        return "buoy_gss|forum_msg".equals(str) || "buoy_gss|forum_msg_v2".equals(str);
    }

    private bge ˎ(ezo o_ezo, bvo o_bvo) {
        if (!ˋ(o_ezo, o_bvo)) {
            return null;
        }
        List<bfo> ˎ = o_ezo.ˎ();
        o_ezo.ॱ(o_bvo);
        bge o_bge = new bge();
        for (bfo o_bfo : ˎ) {
            if (ˎ(o_bfo.ˎ())) {
                BuoyForumMessageProfiles ˊ = o_bfo.ˊ();
                if (ˊ == null) {
                    return null;
                }
                if (ˊ.ˊ() > 0) {
                    o_bge.ˋ(true);
                    if (o_bvo.ˋ()) {
                        o_bge.ˊ(o_bge.ˏ() + ˊ.ˊ());
                    }
                }
                if (ˊ.ˋ() > 0) {
                    o_bge.ˋ(true);
                    if (o_bvo.ˏ()) {
                        o_bge.ˊ(o_bge.ˏ() + ˊ.ˋ());
                    }
                }
                if (ˊ.ˎ() > 0) {
                    o_bge.ˋ(true);
                    if (o_bvo.ˎ()) {
                        o_bge.ˊ(o_bge.ˏ() + ˊ.ˎ());
                    }
                }
                if (ˊ.ॱ() > 0) {
                    o_bge.ˋ(true);
                    if (o_bvo.ˊ()) {
                        o_bge.ˊ(o_bge.ˏ() + ˊ.ॱ());
                    }
                }
                ˏ(o_bvo, ˊ, o_bge);
                ॱ(o_bvo, ˊ, o_bge);
                return o_bge;
            }
        }
        return o_bge;
    }

    private void ˏ(bvo o_bvo, BuoyForumMessageProfiles buoyForumMessageProfiles, bge o_bge) {
        if (buoyForumMessageProfiles.ˏ() > 0) {
            o_bge.ˋ(true);
            if (o_bvo.ॱ()) {
                o_bge.ˊ(o_bge.ˏ() + buoyForumMessageProfiles.ˏ());
            }
        }
    }

    private void ॱ(bvo o_bvo, BuoyForumMessageProfiles buoyForumMessageProfiles, bge o_bge) {
        if (buoyForumMessageProfiles.ʻ() > 0) {
            o_bge.ˋ(true);
            if (o_bvo.ᐝ()) {
                o_bge.ˊ(o_bge.ˏ() + buoyForumMessageProfiles.ʻ());
            }
        }
    }

    private synchronized void ˏ(int i, bgb o_bgb) {
        synchronized (this.ˊ) {
            this.ˎ.add(o_bgb);
            if (this.ˏ) {
            } else {
                String str;
                this.ˏ = true;
                bvn o_bvn = (bvn) fho.ˏ().ˋ("Message").ॱ(bvn.class);
                if (ContentManager.getInstant().getContext().getPackageName().equals("com.huawei.appmarket") && 2 == i) {
                    str = c.ॱ;
                } else {
                    str = ((bus) fho.ˏ().ˋ("Forum").ॱ(bus.class)).ˎ();
                }
                o_bvn.ˎ(str).ˏ(new fjq<bvo>(this) {
                    final /* synthetic */ bfz ˊ;

                    {
                        this.ˊ = r1;
                    }

                    public void onComplete(fjo<bvo> o_fjo_o_bvo) {
                        synchronized (this.ˊ.ˊ) {
                            for (bgb ˏ : this.ˊ.ˎ) {
                                ˏ.ˏ(o_fjo_o_bvo.ˊ() ? (bvo) o_fjo_o_bvo.ॱ() : null);
                            }
                            this.ˊ.ˎ.clear();
                            this.ˊ.ˏ = false;
                        }
                    }
                });
            }
        }
    }

    public ezo ˎ() {
        GameInfo gameInfo = null;
        fae ˏ = fam.ॱ().ˏ();
        if (ˏ != null) {
            gameInfo = ˏ.getGameInfo();
        }
        return ezs.ˏ().ˋ(gameInfo);
    }

    public int ˏ() {
        ezo ˎ = ˎ();
        if (ˎ != null) {
            return ˎ.ᐝ();
        }
        return 0;
    }

    public boolean ˋ() {
        return ˏ() == 2;
    }
}
